﻿<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/listStyle.css"/>
		<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
		<script src="js/list.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="container">
		    <div class="example-page">
			    <div>
			        <h1>List.js Demo</h1>
			    </div>
		    	<div id="main">
		      		<p class="note"><b>Note</b>: These examples are build using jQuery, but that is not required.</p>
		      
		     		<div class="c1">
		       			<h2>Lovely things list</h2>
		        		<div id="lovely-things-list">
		            		<input class="search" placeholder="搜索可爱的东西" />
		         			<ul class="sort-by">
					            <li class="sort btn" data-sort="name">Sort by name</li>
					            <li class="sort btn" data-sort="category">Sort by category</li>
					        </ul>
					        <ul class="filter">
					            <li class="btn" id="filter-none">Show all</li>
					            <li class="btn" id="filter-games">Only show games</li>
					            <li class="btn" id="filter-beverages">Only show beverages</li>
					        </ul>
		         			<ul class="list">
				            	<li>
					                <img src="img/a1.png" class="thumb" />
					                <h4><span class="name">Monkey Island 2: LeChuck's Revenge</span> <span class="category">Game</span></h4>
				            		<p class="description">Monkey Island 2: LeChuck's Revenge is an adventure game developed and published by LucasArts in 1991. It was the second game of the Monkey Island series, following The Secret...</p>
				            	</li>
						        <li>
						            <img src="img/a2.png" class="thumb" />
						            <h4><span class="name">Good Coffee</span> <span class="category">Beverage</span></h4>
						            <p class="description">Coffee is a brewed beverage with a dark, slightly acidic flavor prepared from the roasted seeds of the coffee plant, colloquially called coffee beans.</p>
						        </li>
						        <li>
						            <img src="img/a3.png" class="thumb" />
						            <h4><span class="name">Full Throttle</span> <span class="category">Game</span></h4>
						        	<p class="description">Full Throttle is a computer adventure game developed and published by LucasArts. It was designed by Tim Schafer, who would later go on to design the critically acclaimed titles Grim Fandango, Psychonauts and Brütal Legend.</p>
						      	</li>
						        <li>
							        <img src="img/a1.png" class="thumb" />
							        <h4><span class="name">Brooklyn Lager</span> <span class="category">Beverage</span></h4>
							        <p class="description">Brooklyn Brewery was started in 1987 by former Associated Press correspondent Steve Hindy and former Chemical Bank lending officer Tom Potter.</p>
						        </li>
				    		</ul>
		 				</div>
					</div>
				</div>
			</div>
		</div>	
	</body>
</html>
<script type="text/javascript">
	var options = {
    		valueNames: [ 'name', 'description', 'category' ]
		};

	var featureList = new List('lovely-things-list', options);

	$('#filter-games').click(function() {
	    featureList.filter(function(item) {
	    	if (item.values().category == "Game") {
	      		return true;
	   		} else {
	     		return false;
	   		}
	 	});
	    return false;
	});

	$('#filter-beverages').click(function() {
	    featureList.filter(function(item) {
	    	if (item.values().category == "Beverage") {
	     		return true;
	    	} else {
	        	return false;
	    	}
	  	});
    	return false;
	});
	$('#filter-none').click(function() {
	    featureList.filter();
	 	return false;
	});
</script>